package com.wsx.seven.a;



public class Main0010 {

    public static void main(String[] args) {
        int[] people = new int[100];
        for (int i = 0; i < 100; i++) {
            people[i] = i;
        }
        int last = pop(people,3);
        System.out.println("last 的下标:" + last+"\t 代表第"+(last+1)+"个人");
    }

    public static int pop(int[] array,int step) {
        int last = -1;
        int size = 0;
        int trace = 0;
        int count = 0;
        int length = array.length;
        while (size < length) {
            if (array[trace % length] >= 0) {
                count++;
                if (count % step == step - 1) {
                    last = array[trace % length];
                    array[trace % length] = -1;
                    size++;
                }
            }
            trace++;
        }
        return last;
    }

}
